package com.acdc.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.acdc.device.domain.PowerPointInfo;
import com.acdc.device.service.IPowerPointInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用电点管理Controller
 * 
 * @author acdc
 * @date 2025-05-19
 */
@RestController
@RequestMapping("/station/station")
public class PowerPointInfoController extends BaseController
{
    @Autowired
    private IPowerPointInfoService powerPointInfoService;

    /**
     * 查询用电点管理列表
     */
    //@PreAuthorize("@ss.hasPermi('station:station:list')")
    @GetMapping("/list")
    public TableDataInfo list(PowerPointInfo powerPointInfo)
    {
        startPage();
        List<PowerPointInfo> list = powerPointInfoService.selectPowerPointInfoList(powerPointInfo);
        return getDataTable(list);
    }

    /**
     * 导出用电点管理列表
     */
    @PreAuthorize("@ss.hasPermi('station:station:export')")
    @Log(title = "用电点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PowerPointInfo powerPointInfo)
    {
        List<PowerPointInfo> list = powerPointInfoService.selectPowerPointInfoList(powerPointInfo);
        ExcelUtil<PowerPointInfo> util = new ExcelUtil<PowerPointInfo>(PowerPointInfo.class);
        util.exportExcel(response, list, "用电点管理数据");
    }

    /**
     * 获取用电点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:station:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(powerPointInfoService.selectPowerPointInfoById(id));
    }

    /**
     * 新增用电点管理
     */
    @PreAuthorize("@ss.hasPermi('station:station:add')")
    @Log(title = "用电点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PowerPointInfo powerPointInfo)
    {
        return toAjax(powerPointInfoService.insertPowerPointInfo(powerPointInfo));
    }

    /**
     * 修改用电点管理
     */
    @PreAuthorize("@ss.hasPermi('station:station:edit')")
    @Log(title = "用电点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PowerPointInfo powerPointInfo)
    {
        return toAjax(powerPointInfoService.updatePowerPointInfo(powerPointInfo));
    }

    /**
     * 删除用电点管理
     */
    @PreAuthorize("@ss.hasPermi('station:station:remove')")
    @Log(title = "用电点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(powerPointInfoService.deletePowerPointInfoByIds(ids));
    }
}
